(function () {
    var serverData = {};
    var serverTable;
    //查询
    jQuery('#search_btn').on('click',function(){
        serverData.key=jQuery('#search').val();
        serverTable.draw();
    })
    //撤销查询
    jQuery('#reset').on("click",function()
    {
        jQuery('#search').val('');
        serverData.key ='';
        serverTable.draw();
    });
    
    jQuery(document).ready(function () {
    	serverData.sContractType = '备件合同'; 
        serverTable = jQuery('#dataTable').DataTable({
        	"serverSide": true,
        	"ordering": false,
        	"ajax": {
        		"dataType": "json",
        		"type": "get",
        		"cache": false,
        		"url":window.rootPath+ '/ui/payHostDetails/getMyTrance',
        		"data": function (d) {
        			return $.extend({}, d, serverData);
        		}
        	},
            "columns" : [{
                            data : null,
                            defaultContent : ""// 排序   1
                        },                       
        	            {
                            data: 'dPaidDate',
                            render : function(data,
                                              type, full,
                                              meta) {
                                if (data) {
                                    return moment(data).format("YYYY-MM-DD");
                                }
                            }
                        },
        	            {
        	                data: 'demanderCode'
        	            },
        	            {
        	                data: 'superior'
        	                
        	            },
        	            {
        	                data: 'nPaidStage'
        	                
        	            },
        	            {
       		        	 	data: 'cPaidType'
        	            },
        	            {
        	                data: 'sFund'
        	                
        	            },
        	            {
        	                data: 'areaName'
        	                
        	            },
        	            {
        	                data: 'sPayMan'
        	                
        	            },
        	            {
        	                data: 'quotationOfficer'
        	                
        	            },
        	            {
        	                data: 'sMemo'
        	            }],
            "drawCallback": function (oSettings) {
                var k = 0;
                var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;

                for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
                    $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
                    k++;
                }
            }
        });
    });
})();